<#assign menuId=4>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>上传尾查报告-${Application.systemName!}</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- bootstrap 3.0.2 -->
    <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- font Awesome -->
    <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <!-- Ionicons -->
    <link href="../css/ionicons.min.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />
	<!--datetimepicker-->
	<link rel="stylesheet" type="text/css" href="../css/datetimepicker/bootstrap-datetimepicker.min.css"/>
	
	<link rel="stylesheet" type="text/css" href="../css/myself.css"/>
	<link rel="stylesheet" type="text/css" href="../css/bootstrapValidator.min.css"/>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        ul li{
            list-style: none;
            margin-top: 10px;
        }
        .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
		    vertical-align: middle;
		}
		.table tr td:nth-child(1) {
			text-align: right;
		}
        .pull-left{
            border-left: 6px solid #3882FF;
            padding: 0 5px;
            font-size: 14px;
            margin: 10px 0;
        }
     
        
        /* 上传按钮样式 */
        .file {
			    position: relative;
			    display: inline-block;
			    background: #D0EEFF;
			    border: 1px solid #99D3F5;
			    border-radius: 4px;
			    padding: 4px 12px;
			    overflow: hidden;
			    color: #1E88C7;
			    text-decoration: none;
			    text-indent: 0;
			    line-height: 20px;
			}
			.file input {
			    position: absolute;
			    font-size: 100px;
			    right: 0;
			    top: 0;
			    opacity: 0;
			}
			.file:hover {
			    background: #AADFFD;
			    border-color: #78C3F3;
			    color: #004974;
			    text-decoration: none;
			}
			.file_name{
	        	display: inline-block;
	        	width: auto;
	        	height: 30px;
	        	line-height: 30px;
	        	color: #3882FF;
	        	position: relative;
	        	top: -10px;
	        	margin: 0 5px;
	        	padding:5px;
    			font-size: 14px;
	        }
	        .file_fa{
	        	position: relative;
	        	width: 480px;
	        }
	        .btn-old{
                display: inline-block;
			    width: auto;
			    height: 30px;
			    line-height: 30px;
			    color: #3882FF;
			    position: relative;
			    top: -10px;
			    margin: 0 5px;
			    padding: 5px;
			    font-size: 14p
           
        	}
	        .file_fa button{
	        	position: absolute;
	        }
	        small.help-block{
	        	color:red;
	        }
    </style>
</head>
<body class="skin-blue">
<!-- header logo: style can be found in header.less -->
<#include "../header.html"/>
<div class="wrapper row-offcanvas row-offcanvas-left">
    <!-- Left side column. contains the logo and sidebar -->
    <#include "../menu.html"/>

    <!-- Right side column. Contains the navbar and content of the page -->
    <aside class="right-side">
        <section class="content-header">
            <h1 >上传尾查报告
            </h1>
          

        </section>
        <!-- Content Header (Page header) -->
        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="box"  style="padding: 20px;">
                        <div class="clearfix center">
                            <span class="pull-left four-font">填写基本信息</span>
                        </div>
                        <div class="center">
                        <form id="form">
                            <table class="table table-bordered custormView">

                                <tr>
                                	<td width="10%">选择计划中查时间段</td>
                                    <td>
                                    	<div class="row">
                                        <div class="col-xs-3">
                                            <div class="input-group date form_datetime">
												<input class="form-control" type="text" name="middleCheckStartime" value="<#if productionPattern.middleCheckStarttime??>${productionPattern.middleCheckStarttime?string("yyyy-MM-dd HH:mm")}</#if>"> 
												<span class="input-group-addon">
													<span class="glyphicon glyphicon-th"></span>
												</span>
											</div>
                                        </div>
                                        <div class="col-xs-1">
                                            至
                                        </div>
                                        <div class="col-xs-3">
                                            <div 
								class="input-group date form_datetime">
								<input class="form-control" type="text"
									name="middleCheckEndime" value="<#if productionPattern.middleCheckEndtime??>${productionPattern.middleCheckEndtime?string("yyyy-MM-dd HH:mm")}</#if>"> <span
									class="input-group-addon"><span
									class="glyphicon glyphicon-th"></span></span>
							</div>
                                        </div>
                                    </div>
                                
                                    </td>
                                </tr>
                                <tr><td>上传中查报告</td>
                                    <td>
												<div class="input-group">
												<#list middleFiles as middleFile>
                                       				<div class="file_fa">
                                    					
														<span class="file_name">${middleFile.originName!}</span>
														<a href="javascript:" class="btn-old" data-id="${middleFile.id!}">删除</a>
                                    				</div>
		                                            </#list>
		                                            <div class="file_fa">
                                    					<a href="javascript:;" class="file">
														    <input type="file" name="middleFile">点击上传文件
														</a>
														<span class="file_name"></span>
                                    				</div>
								</div>
                                        <p></p><div class="form-group textarea">
                                            <textarea name="uploadMiddleMemo" class="form-control" rows="2" >${productionPattern.uploadMiddleMemo!}</textarea>
                                        </div>
                                    </td>
                                </tr>
                               
								
								
                                <tr>
                                <td>尾查时间 </td>
                                    <td>
                                    <div 
								class="input-group date form_datetime col-md-5">
								<input class="form-control" type="text"
									name="lastCheckTime" value="<#if productionPattern.lastCheckTime??>${productionPattern.lastCheckTime?string("yyyy-MM-dd HH:mm")}</#if>"> <span
									class="input-group-addon"><span
									class="glyphicon glyphicon-th"></span></span>
							</div>
							</td>
                                </tr>
                                <tr><td>上传尾查报告</td>
                                    <td><div class="input-group">
								<#list lastFiles as lastFile>
		                                       <div class="file_fa">
                                    					
														<span class="file_name">${lastFile.originName!}</span>
														<a href="javascript:" class="btn-old" data-id="${lastFile.id!}">删除</a>
                                    				</div>
		                                            </#list>
		                                            <div class="file_fa">
                                    					<a href="javascript:;" class="file">
														    <input type="file" name="lastFile">点击上传文件
														</a>
														<span class="file_name"></span>
                                    				</div>
								</div><p></p>
                                        <div class="form-group textarea">
                                            <textarea class="form-control" name="uploadLastMemo" rows="2" >${productionPattern.uploadLastMemo!}</textarea>
                                        </div>
                                    </td>
                                </tr>
                                
                            </table>
                           </form>
                           

                            <p>
                                <button type="button" class="btn btn-primary" onclick="saveLastReport()" style="margin-right: 10px;">保存</button>
                               
                                <button type="button" class="btn btn-default" onclick="window.location.href='../productionorder/list'">取消</button>
                            </p>
                        </div>
                    </div><!-- /.box -->


                </div><!-- /.col -->

            </div><!-- /.row -->

        </section>

        <!-- Main content -->
        <section class="content">


        </section><!-- /.content -->


    </aside><!-- /.right-side -->
</div><!-- ./wrapper -->

<!-- jQuery 2.0.2 -->
<script src="../js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../js/bootstrap.min.js" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="../js/AdminLTE/app.js" type="text/javascript"></script>
<script src="../js/jquery.form.min.js"></script>
<!--datepickes-->
<script src="../js/plugins/datetimerpicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
	
		<script src="../js/plugins/datetimerpicker/locales/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
        <script src="../js/bootstrapValidator.min.js" type="text/javascript"></script>
</body>
<script type="text/javascript">


$(function() {
    $('.form_datetime').datetimepicker({
    	format: 'yyyy-mm-dd hh:00',
       	language:  'zh-CN',  
        weekStart: 1,  
        todayBtn:  1,  
        autoclose: 1,  
        todayHighlight: 1,  
        startView: 2,  
        forceParse: 0,  
        showMeridian: 0,
        minView: 1,
        startDate: new Date()
    });
    var  getFilename = function(file){
        var filePath=$(file).val();
        filePath=filePath.substring(filePath.lastIndexOf('\\')+1);
        $(file).parent().next().html(filePath);
    }
    var  removeAttach=function(){
    	$(this).parent().remove();
    }
    var addMiddleFile = function(){
    	getFilename($(this));
    	if($(this)[0].files[0]){
    		if($(this).parent().nextAll().length==1){
    			var button=$('<button type="button" class="btn btn-default btn-sm">删除</button>')
    			$(this).parent().next().after(button);
    			button.click(removeAttach);
    			var div=$('<div class="file_fa"><a href="javascript:;" class="file"><input type="file" name="middleFile">点击上传文件</a>'
    					+'<span class="file_name"></span></div>');
    			div.find(':file').change(addMiddleFile);
    			$(this).parent().parent().after(div);
    		}
    	}else{
    		if($(this).parent().nextAll().length==1){
    			$(this).parent().next().remove();
    		}else{
    			$(this).parent().remove();
    		}
    	}
    }
    var addLastFile = function(){
    	getFilename($(this));
    	if($(this)[0].files[0]){
    		if($(this).parent().nextAll().length==1){
    			var button=$('<button type="button" class="btn btn-default btn-sm">删除</button>')
    			$(this).parent().next().after(button);
    			button.click(removeAttach);
    			var div=$('<div class="file_fa"><a href="javascript:;" class="file"><input type="file" name="lastFile">点击上传文件</a>'
    					+'<span class="file_name"></span></div>');
    			div.find(':file').change(addLastFile);
    			$(this).parent().parent().after(div);
    		}
    	}else{
    		if($(this).parent().nextAll().length==1){
    			$(this).parent().next().remove();
    		}else{
    			$(this).parent().remove();
    		}
    	}
    }
    $(':file[name="middleFile"]').change(addMiddleFile);
    $(':file[name="lastFile"]').change(addLastFile);
    $(':file[name="oldMiddleFile"]').change(addMiddleFile);
    $(':file[name="oldLastFile"]').change(addLastFile);
    $(".btn-old").click(function(){
    	var id = $(this).attr("data-id");
    	var _this =$(this);
    	confirm("是否确定删除?",function(flag){
    		console.log(flag)
    		if(flag){
    			
            	$.ajax({
            	    type: "POST",
            	    dataType: "json",
            	    url: "../businessfile/delete",
            	    data:{id:id},
            	    
            	    success : function(map) {  
            	    	if(map.head.respCode=="0000000"){
            	    		success("删除成功",function(){
            	    			
                	        	_this.parent().remove();
            	        	});
            	        	
            	        }else{
            	        	alert(map.body);
            	        }
            	    },  
            	    error : function(map) {  
            	        alert("出现错误，请刷新页面");  
            	    }  

            	});
    		}
    		
    	});
    	
    });
});


function saveLastReport(){
	$('#form').data('bootstrapValidator').validate();  
    if(!$('#form').data('bootstrapValidator').isValid()) return false;
	$("#form").ajaxSubmit({
	    type: "POST",
	    dataType: "json",
	    url: "saveLastReport",
	    data:{id:${productionPatternId}},
	    
	    success : function(map) {  
	    	if(map.head.respCode=="0000000"){
	        	success("保存成功",function(){
	        		window.location.href='../productionorder/list';
	        	});
	        	
	        }else{
	        	alert(map.body);
	        }
	    },  
	    error : function(map) {  
	        alert("出现错误，请刷新页面");  
	    }  

	});
}

function checkForm(){
	$('#form').bootstrapValidator({
		  fields: {
		      middleCheckStartime: {
		    	  trigger:'blur change',
		          validators: {
		              regexp: {
	                        regexp: /^\w{4}-\w{2}-\w{2} \w{1,2}:\w{2}$/,
	                        message: '中查时间段起始时间不符'
	                  }
		          }
		      },
		      middleCheckEndime: {
		    	  trigger:'blur change',
		    	  validators: {
		    		  regexp: {
	                        regexp: /^\w{4}-\w{2}-\w{2} \w{1,2}:\w{2}$/,
	                        message: '中查时间段截止时间不符'
	                  }
		          }
		      },
		      lastCheckTime:{
		    	  trigger:'blur change',
		    	  validators: {
		              regexp: {
	                        regexp: /^\w{4}-\w{2}-\w{2} \w{1,2}:\w{2}$/,
	                        message: '尾查时间不符'
	                  }
		          }
		      }
		  }
	});
}

$(function(){
	checkForm();
})

</script>
</html>
